<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            text-align: center;
        }
    </style>
</head>
<body>

    <button type="button" onclick="openNewWindow()">打开新窗口</button>
    <button type="button" onclick="window.close()">关闭窗口</button>
    <button type="button" onclick="location.href = 'http://www163.com'">点我跳转</button>

    <hr>
    <button type="button" onclick="showAlert()">普通弹框</button>
    <button type="button" onclick="showConfirm()">确认弹框</button>
    <button type="button" onclick="showPrompt()">输入弹框</button>

    <hr>

    <!--计算器-->
    <input type="text" id="n1">
    <span>+</span>
    <input type="text" id = "n2">
    <button type="button" onclick="calc()">=</button>
    <input type="text" id="result" readonly>

</body>
<script type="text/javascript">
    /*
    * 计算器计算方法
    * */
    function calc() {
        var n1 = document.getElementById("n1");
        n1 = parseInt(n1.value);

        var n2 = document.getElementById("n2");
        n2 = parseInt(n2.value);

        var n3 = n1 + n2;
        var result = document.getElementById("result");
        result.value = n3;
    }


    function openNewWindow() {
        window.open("http://wwww.baidu.com");
    }
    function showAlert() {
        alert("普通弹框");
    }

    //确认按钮
    function showConfirm() {
       var s = confirm("我帅吗？");
       if(s){
           alert("有眼光");
       }else
       {
           alert("xia");
       }

    }

    //输入按钮
    function showPrompt() {
        var str = prompt("你从哪里来");
       // alert("欢迎来"+str+"的朋友");//如果点击取消值为null
    //演示动态语言特性
    alert(eval(str));

    }

</script>
</html>